package ckw.manager;

import java.util.List;

import ckw.database.model.Election;
import ckw.database.model.ElectionChanges;
import ckw.database.model.ElectionNode;
import ckw.database.model.ElectionNonResidentVoter;
import ckw.database.model.ElectionResidentVoter;
import ckw.database.model.Member;
import ckw.database.model.Node;
import ckw.database.model.Voter;
import core.cards.election.model.ElectionResultBackend;
import core.exceptions.CommunicationInitiationException;
import core.exceptions.ObjectDeleteException;
import core.exceptions.ObjectUpdateException;
import core.exceptions.PortInUseException;
import core.exceptions.WrongActionException;

public interface ManagerController {
	/* Different */

	public void setUp() throws CommunicationInitiationException, PortInUseException;

	public void shutDown();

	public void sendConfigurations();

	/* Node */

	public Node saveNode(Node node);

	public void deleteNode(Node node) throws ObjectDeleteException;

	public Node updateNode(Node node);

	public Node getBaseNode();

	public List<Node> getAllRkwNodes();

	public Boolean isNodeLocatorUriTaken(String ip, String port);

	public Node getNode(Node node);

	/* Member */

	public Boolean isMemberIdentificationFieldTaken(String identificationField);

	public List<Member> getAllMembers();

	public Member storeMember(Member member) throws ObjectUpdateException;

	public void deleteMember(Member member) throws ObjectDeleteException;

	/* Election */

	public Election getElection(Long id);

	public List<Election> getAllElections();

	public void addNonResidentVoter(Election election, Voter voter);

	public void addResidentVoter(Election election, Voter voter);

	public Election saveElection(Election election);

	public Election updateElection(Election election) throws WrongActionException;

	public void deleteElection(Election election) throws ObjectDeleteException;

	public void sendElectionConfiguration(Election election);

	/* ElectionNode */

	public void addMember(ElectionNode electionNode, Member member);

	public void removeMember(ElectionNode electionNode, Member member);

	/* ElectionNonResidentVoter */

	public void removeNonResidentVoter(ElectionNonResidentVoter electionNonResidentVoter);

	/* ElectionResidentVoter */

	public void removeResidentVoter(ElectionResidentVoter electionResidentVoter);

	/* Voter */

	public Boolean isVoterIdentificationFieldTaken(String identificationField);

	public Voter storeVoter(Voter voter) throws ObjectUpdateException;

	public void deleteVoter(Voter voter) throws ObjectDeleteException;

	public List<Voter> getAllVoters();

	public List<Voter> findVotersLike(String text);

	public Voter getVoterByIdentificationField(String identificationField);

	/* Testy */

	public List<ElectionChanges> getAllElectionChanges();

	public ElectionChanges getElectionChanges(String nodeUri, Long electionIdentificationField);

	public ElectionResultBackend getElectionResult(Election selectedElection);

	public Node getMainNode();

}
